package com.zy.swagger.converter;

import com.zy.swagger.dto.RequestRecordDTO;
import com.zy.swagger.entity.RequestRecord;
import com.zy.swagger.vo.RequestRecordVO;
import org.springframework.beans.BeanUtils;

/**
 * (表t_request_record)数据实体转换辅助类
 *
 * @author ZY
 * @date 2021-04-24 20:14:00
 */
public class RequestRecordConverter {

    /**
     * 私有化构造器
     */
    private RequestRecordConverter() {
    }

    /**
     * 实体类转DTO
     *
     * @param entity 实体类
     * @return 转换后的对象
     */
    public static RequestRecordDTO covertToDTO(RequestRecord entity) {
        RequestRecordDTO dto = new RequestRecordDTO();
        BeanUtils.copyProperties(entity, dto);
        return dto;
    }

    /**
     * 实体类转VO
     *
     * @param entity 实体类
     * @return 转换后的对象
     */
    public static RequestRecordVO convertToVO(RequestRecord entity) {
        RequestRecordVO vo = new RequestRecordVO();
        BeanUtils.copyProperties(entity, vo);
        return vo;
    }

    /**
     * DTO转实体类
     *
     * @param dto 参数对象
     * @return 转换后的实体类对象
     */
    public static RequestRecord convertFromDTO(RequestRecordDTO dto) {
        RequestRecord entity = new RequestRecord();
        BeanUtils.copyProperties(dto, entity);
        return entity;
    }

    /**
     * VO转实体类
     *
     * @param vo 参数对象
     * @return 转换后的实体类对象
     */
    public static RequestRecord convertFromVO(RequestRecordVO vo) {
        RequestRecord entity = new RequestRecord();
        BeanUtils.copyProperties(vo, entity);
        return entity;
    }

}